#include "network/NetworkManager.h"
#include <assert.h>
#include <interfacelib/frame/handlemanager.h>

NetworkManager::NetworkManager() : m_socket( NULL )
{
	SAFE_DELETE( m_socket );
}

NetworkManager::~NetworkManager()
{
}

bool NetworkManager::connectServer( char *ip, u_short port )
{
	SAFE_DELETE( m_socket );
	m_socket = m_socketManager.createTCPSocket();

	m_socket->connect( ip, port );
	m_socket->setNotificationWnd( interfacelib::Frame::HandleManager::getInstance()->getWindowHandle() );

	return ( true );
}

bool NetworkManager::send( netlib::packet::Packet *packet )
{
	assert( packet );

	if ( !m_socket ) return ( false );
	
	m_socket->send( packet );
	return ( true );
}